package com.gzx.plugin.data.wxjk.sync.dao;

import com.gzx.plugin.data.wxjk.sync.pojo.SssjCustomerDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

@Mapper
public interface SssjDao {

    @Insert({
            "<script>",
            "INSERT INTO data_wxjk_sssj",
            "  <trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">",
            "    <if test=\"businessId != null\">business_id,</if>",
            "    <if test=\"contractNo != null\">contract_no,</if>",
            "    <if test=\"custName != null\">cust_name,</if>",
            "    <if test=\"idNo != null\">id_no,</if>",
            "    <if test=\"phone != null\">phone,</if>",
            "    <if test=\"sex != null\">sex,</if>",
            "    <if test=\"resAddress != null\">res_address,</if>",
            "    <if test=\"residAddress != null\">resId_address,</if>",
            "    <if test=\"registrationDate != null\">registration_date,</if>",
            "    <if test=\"registrationChannel != null\">registration_channel,</if>",
            "    <if test=\"contractDate != null\">contract_date,</if>",
            "    <if test=\"lendingSide != null\">lending_side,</if>",
            "    <if test=\"lendingSideSecond != null\">lending_side_second,</if>",
            "    <if test=\"serviceName != null\">service_name,</if>",
            "    <if test=\"guaranteeName != null\">guarantee_name,</if>",
            "    <if test=\"assigneeName != null\">assignee_name,</if>",
            "    <if test=\"orderStatus != null\">order_status,</if>",
            "    <if test=\"outPeriod != null\">out_period,</if>",
            "    <if test=\"productName != null\">product_name,</if>",
            "    <if test=\"prepaymentDate != null\">prepayment_date,</if>",
            "    <if test=\"billDay != null\">bill_day,</if>",
            "    <if test=\"deliveryDate != null\">delivery_date,</if>",
            "    <if test=\"contractPenalty != null\">contract_penalty,</if>",
            "    <if test=\"coYearRate != null\">co_year_rate,</if>",
            "    <if test=\"currentPenalty != null\">current_penalty,</if>",
            "    <if test=\"loanAmount != null\">loan_amount,</if>",
            "    <if test=\"loanPeriod != null\">loan_period,</if>",
            "    <if test=\"repaymentMode != null\">repayment_mode,</if>",
            "    <if test=\"bankCardNo != null\">bank_card_no,</if>",
            "    <if test=\"bankName != null\">bank_name,</if>",
            "    <if test=\"supportPublic != null\">support_public,</if>",
            "    <if test=\"outOverPeriod != null\">out_over_period,</if>",
            "    <if test=\"overdueDate != null\">overdue_date,</if>",
            "    <if test=\"overdueTotalAmount != null\">overdue_total_amount,</if>",
            "    <if test=\"cleanLoanTotalAmount != null\">clean_loan_total_amount,</if>",
            "    <if test=\"collContent != null\">coll_content,</if>",
            "    create_time",
            "  </trim>",
            "  <trim prefix=\"VALUES (\" suffix=\")\" suffixOverrides=\",\">",
            "    <if test=\"businessId != null\">#{businessId},</if>",
            "    <if test=\"contractNo != null\">#{contractNo},</if>",
            "    <if test=\"custName != null\">#{custName},</if>",
            "    <if test=\"idNo != null\">#{idNo},</if>",
            "    <if test=\"phone != null\">#{phone},</if>",
            "    <if test=\"sex != null\">#{sex},</if>",
            "    <if test=\"resAddress != null\">#{resAddress},</if>",
            "    <if test=\"residAddress != null\">#{residAddress},</if>",
            "    <if test=\"registrationDate != null\">#{registrationDate},</if>",
            "    <if test=\"registrationChannel != null\">#{registrationChannel},</if>",
            "    <if test=\"contractDate != null\">#{contractDate},</if>",
            "    <if test=\"lendingSide != null\">#{lendingSide},</if>",
            "    <if test=\"lendingSideSecond != null\">#{lendingSideSecond},</if>",
            "    <if test=\"serviceName != null\">#{serviceName},</if>",
            "    <if test=\"guaranteeName != null\">#{guaranteeName},</if>",
            "    <if test=\"assigneeName != null\">#{assigneeName},</if>",
            "    <if test=\"orderStatus != null\">#{orderStatus},</if>",
            "    <if test=\"outPeriod != null\">#{outPeriod},</if>",
            "    <if test=\"productName != null\">#{productName},</if>",
            "    <if test=\"prepaymentDate != null\">#{prepaymentDate},</if>",
            "    <if test=\"billDay != null\">#{billDay},</if>",
            "    <if test=\"deliveryDate != null\">#{deliveryDate},</if>",
            "    <if test=\"contractPenalty != null\">#{contractPenalty},</if>",
            "    <if test=\"coYearRate != null\">#{coYearRate},</if>",
            "    <if test=\"currentPenalty != null\">#{currentPenalty},</if>",
            "    <if test=\"loanAmount != null\">#{loanAmount},</if>",
            "    <if test=\"loanPeriod != null\">#{loanPeriod},</if>",
            "    <if test=\"repaymentMode != null\">#{repaymentMode},</if>",
            "    <if test=\"bankCardNo != null\">#{bankCardNo},</if>",
            "    <if test=\"bankName != null\">#{bankName},</if>",
            "    <if test=\"supportPublic != null\">#{supportPublic},</if>",
            "    <if test=\"outOverPeriod != null\">#{outOverPeriod},</if>",
            "    <if test=\"overdueDate != null\">#{overdueDate},</if>",
            "    <if test=\"overdueTotalAmount != null\">#{overdueTotalAmount},</if>",
            "    <if test=\"cleanLoanTotalAmount != null\">#{cleanLoanTotalAmount},</if>",
            "    <if test=\"collContent != null\">#{collContent},</if>",
            "    now()",
            "  </trim>",
            "</script>"
    })
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insertSelective(SssjCustomerDto record);

    @Select("SELECT x.* FROM `data`.data_wxjk_sssj x WHERE x.business_id = #{businessId}")
    List<HashMap<String, Object>> query(Integer businessId);
}
